package com.ahao.aggregation.utils;

import android.util.Log;

import com.ahao.abstraction.IChannel;

public class ChannelFactory {
    public static IChannel createChannel(String channelName) {
        try {
            Class<?> channelClass = Class.forName("com.ahao." + channelName + ".AHAOSDK");
            Object channelInstance = channelClass.newInstance();
            LogUtils.info("createChannel: " + channelInstance);
            if (channelInstance instanceof IChannel) {
                return (IChannel) channelInstance;
            } else {
                throw new IllegalArgumentException("The provided class does not implement IChannel interface.");
            }
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
            e.printStackTrace(); // 处理异常
            return null;
        }
    }
}
